package com.itheima.service.db.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.Admin;
import com.itheima.mapper.AdminMapper;
import com.itheima.service.db.AdminService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override//根据用户名查询管理者详情
    public Admin findAdminByUsername(String username) {
        QueryWrapper qw=new QueryWrapper();
        qw.eq("username",username);
        Admin admin = adminMapper.selectOne(qw);
        return admin;
    }

    @Override
    public Admin findByOpenId(String openId) {
        return adminMapper.selectOne(new QueryWrapper<Admin>().eq("open_id",openId));
    }

    @Override
    public void saveAdmin(Admin admin) {
        adminMapper.insert(admin);
    }
}
